<?php

	$pilot = $_SERVER["argv"][1];

	include "kernel.php";

    $link = ConnectToBase();


	$TPmain->Necho = 0;
	$bd = mktime();
	$d = $bd;

    $i=0;

    	$i++;

     	ob_start();

        $link = ConnectToBase ();

        echo "PARSING PILOT #$pilot\r\n";

        echo "deleting all ships stat\r\n";
        mysql_query("update finalpilots set cv='0', bb='0', ca='0', dd='0', ss='0' where pilotid='$pilot'");

        echo "Recalculate_Pilot_Rank...\r\n";
		$rank = Recalculate_Pilot_Rank ($pilot);

        echo "Update_Pilot_Rank...\r\n";
    	Update_Pilot_Rank ($pilot,$rank);

        echo "Update_Pilot_Common_Stat...\r\n";
		UpdatePilotCommonStat ($pilot);

        echo "Recalculate_Pilot_Awards...\r\n";
    	$awd = Recalculate_Pilot_Awards ($pilot);

        echo "Update_Pilot_Awards...\r\n";
    	Update_Pilot_Awards ($pilot,$awd);

        echo "UpdateShipsForPilot...\r\n";
        UpdateShipsForPilot($pilot);

		$d = mktime() - $d;
    	echo "$i. Done in ".$d."\r\n";
        $d = mktime();

        echo "\r\n";
        ob_end_flush();


        $bd = mktime() - $bd;
    	echo "Script done. \r\n Pilots parsed: $i \r\n In $bd seconds\r\n";



?>